package com.dubbo.consumer;

import com.dubbo.api.UserServiceI;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class UserInit implements CommandLineRunner {

    //会拉取注册中心的服务缓存在本地，即使注册中心宕机，之前的服务也能用，但是新的服务无法发现
    @Reference(version = "1.0",parameters = {"unicast","false"})
    private UserServiceI userServiceI;

    @Override
    public void run(String... args) throws Exception {
        System.out.println(userServiceI.selectUserById(2));

    }
}
